package com.uetoken.cn.fragment;

import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.uetoken.cn.R;
import com.uetoken.cn.adapter.ShipmentTabelAdapter;
import com.uetoken.cn.adapter.model.ShipmentTabelMobel;
import com.uetoken.cn.base.BaseFragment;
import com.uetoken.cn.manager.UEDataManager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class IsShipmentFragment extends BaseFragment {

    @BindView(R.id.line1)
    View line1;
    @BindView(R.id.reciprocalAccountNumber1Tv)
    TextView reciprocalAccountNumber1Tv;
    @BindView(R.id.topupCodeTv)
    TextView topupCodeTv;
    @BindView(R.id.denominationBtn)
    TextView denominationBtn;
    @BindView(R.id.timeTv)
    TextView timeTv;
    @BindView(R.id.shipmentTableLayout)
    LinearLayout shipmentTableLayout;
    @BindView(R.id.line2)
    View line2;
    @BindView(R.id.tableRecyclerView)
    RecyclerView mTableRecyclerView;
    @BindView(R.id.line3)
    View line3;

    private ShipmentTabelAdapter mShipmentTabelAdapter;
    private DividerItemDecoration vDividerItemDecoration = null;
    private List<ShipmentTabelMobel> mShipmentTabelMobelList;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_is_shipment, container, false);
        ButterKnife.bind(this, view);
        initView();
        initData();
        return view;
    }

    private void initView() {
        vDividerItemDecoration = new DividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL);
        mTableRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        mTableRecyclerView.addItemDecoration(vDividerItemDecoration);
    }

    private void initData() {
        getDenomination();
    }

    private void getDenomination() {
        mShipmentTabelMobelList = new ArrayList<>();

        ShipmentTabelMobel model1 = new ShipmentTabelMobel();
        model1.setID("56*****41");
        model1.setAccountNumber("肖**(16****9)");
        model1.setTopupCode("SVC");
        model1.setDenomination("100");
        model1.setTime("2018-06-12 12:40:20");
        ShipmentTabelMobel model2 = new ShipmentTabelMobel();
        model2.setID("57*****42");
        model2.setAccountNumber("肖**(26****9)");
        model2.setTopupCode("SVC");
        model2.setDenomination("10000");
        model2.setTime("2018-06-13 12:40:21");
        ShipmentTabelMobel model3 = new ShipmentTabelMobel();
        model3.setID("58*****43");
        model3.setAccountNumber("肖**(36****9)");
        model3.setTopupCode("SVC");
        model3.setDenomination("500");
        model3.setTime("2018-06-14 12:40:22");
        ShipmentTabelMobel model4 = new ShipmentTabelMobel();
        model4.setID("59*****44");
        model4.setAccountNumber("肖**(46****9)");
        model4.setTopupCode("SVC");
        model4.setDenomination("1000");
        model4.setTime("2018-06-15 12:40:23");
        ShipmentTabelMobel model5 = new ShipmentTabelMobel();
        model5.setID("50*****45");
        model5.setAccountNumber("肖**(56****9)");
        model5.setTopupCode("SVC");
        model5.setDenomination("5000");
        model5.setTime("2018-06-16 12:40:24");

        mShipmentTabelMobelList.add(model1);
        mShipmentTabelMobelList.add(model2);
        mShipmentTabelMobelList.add(model3);
        mShipmentTabelMobelList.add(model4);
        mShipmentTabelMobelList.add(model5);

        UEDataManager.getInstance().setShipmentTabelMobelList(mShipmentTabelMobelList);

        mShipmentTabelAdapter = new ShipmentTabelAdapter(getActivity());
        mTableRecyclerView.setAdapter(mShipmentTabelAdapter);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }
}
